from neo4j import GraphDatabase
DEFAULT_URI = "bolt://localhost:7687"
DEFAULT_USER = "neo4j"
DEFAULT_PASS = "123456"
import pandas as pd

import os
driver = GraphDatabase.driver(DEFAULT_URI, auth=(DEFAULT_USER, DEFAULT_PASS))

def get_companys(driver):
    cypter = '''
    call {Match (n:`企业`) return n} return n.name,n.clusterId'''
    ids = []
    with driver.session() as session:
        results = session.run(cypter)
        for result in results:
            ids.append((result[0],str(result[1])))
    return ids
result = get_companys(driver)
with open("company.csv",'w') as frwrite:
    frwrite.write("company_name,cluster_id\n")
    for item in result:
        frwrite.write(",".join(item)+"\n")

